package com.loiot.baqi.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.loiot.baqi.pojo.TaskScheduleHeartbeat;

/**
 * 定时心跳 访问层。
 * 
 * @author  wangzx 
 * @creation 2016-05-16
 */
@Repository("taskScheduleHeartbeatDao")
public class TaskScheduleHeartbeatDao extends SqlSessionDaoSupport{
    
    /**
     * 添加 定时心跳
     * 
     * @param p 参数对象
     */
    public TaskScheduleHeartbeat addTaskScheduleHeartbeat(TaskScheduleHeartbeat p)throws Exception {
        this.getSqlSession().insert("TaskScheduleHeartbeat.addTaskScheduleHeartbeat", p);
        return p;
    }
    
    /**
     * 修改 定时心跳
     * 
     * @param p 参数对象
     */
    public void updateTaskScheduleHeartbeat(TaskScheduleHeartbeat p)throws Exception {
        this.getSqlSession().update("TaskScheduleHeartbeat.updateTaskScheduleHeartbeat", p);
    }
    
    /**
     * 修改 定时心跳
     * 
     * @param p 参数对象
     */
    public void updateTaskScheduleHeartbeat(HashMap<String,Object> pMap)throws Exception {
        this.getSqlSession().update("TaskScheduleHeartbeat.updateTaskScheduleHeartbeatByMap", pMap);
    }
    
    
    
    /**
     * 删除  定时心跳
     * 
     * @param id 主键
     */
    public void deleteTaskScheduleHeartbeat(java.lang.Long id)throws Exception {
        getSqlSession().delete("TaskScheduleHeartbeat.deleteTaskScheduleHeartbeat", id);
    }
    
    /**
     * 删除  定时心跳
     * 
     * @param id 主键
     */
    public void deleteTaskScheduleHeartbeat(TaskScheduleHeartbeat p)throws Exception {
        getSqlSession().delete("TaskScheduleHeartbeat.deleteTaskScheduleHeartbeat", p);
    }
    
    /**
     * 获得  定时心跳
     * 
     * @param id 定时心跳Id
     * 
     * @return 返回与ID匹配的定时心跳
     */
    public TaskScheduleHeartbeat getTaskScheduleHeartbeatById(java.lang.Long id)throws Exception {
    	HashMap<String, Object> pMap = new HashMap<String, Object>();
    	pMap.put("id", id);
    	return (TaskScheduleHeartbeat) getSqlSession().selectOne("TaskScheduleHeartbeat.getTaskScheduleHeartbeatById", pMap);
    }
    
    /**
     * 获得  定时心跳
     * 
     * @param id 定时心跳Id
     * 
     * @return 返回与ID匹配的定时心跳
     */
    public TaskScheduleHeartbeat getTaskScheduleHeartbeatById(java.lang.Long id,Long accountId)throws Exception {
    	HashMap<String, Object> pMap = new HashMap<String, Object>();
    	pMap.put("id", id);
    	pMap.put("inPerson", accountId);
    	return (TaskScheduleHeartbeat) getSqlSession().selectOne("TaskScheduleHeartbeat.getTaskScheduleHeartbeatById", pMap);
    }
    
    /**
     * 获得  定时心跳
     * 
     * @param id 定时心跳Id
     * 
     */
    public TaskScheduleHeartbeat getTaskScheduleHeartbeat(HashMap<String,Object> pMap)throws Exception {
    	return (TaskScheduleHeartbeat) getSqlSession().selectOne("TaskScheduleHeartbeat.queryTaskScheduleHeartbeatList", pMap);
    }
    
    /**
     * 获得  定时心跳
     * 
     * @param name 定时心跳名称
     * 
     * @return 返回与NAME匹配的定时心跳
     */
    public TaskScheduleHeartbeat getTaskScheduleHeartbeatByName(String name)throws Exception {
        return null;
        //return (TaskScheduleHeartbeat) getSqlSession().selectOne("TaskScheduleHeartbeat.getTaskScheduleHeartbeatByName", name);
    }
    
    
    
    /**
     * 查询  定时心跳列表条数
     * 
     * @param name 定时心跳名称
     * @return 定时心跳列表条数
     */
    
    public int getTaskScheduleHeartbeatListCount(HashMap<String,Object> pMap)throws Exception {
        return (Integer) getSqlSession().selectOne("TaskScheduleHeartbeat.getTaskScheduleHeartbeatListCount", pMap);
    }

    /**
     * 查询 定时心跳列表
     * 
     * @param name 定时心跳名称
     * @param skipResults 跳过的记录数
     * @param maxResults 最大的记录数
     * @return 定时心跳列表
     */
    public List<TaskScheduleHeartbeat> queryTaskScheduleHeartbeatList(HashMap<String, Object> pMap, int skipResults, int maxResults)throws Exception {
    	pMap.put("skipResults", skipResults);
    	pMap.put("maxResults", maxResults);
        return getSqlSession().selectList("TaskScheduleHeartbeat.queryTaskScheduleHeartbeatList", pMap);
    }
    
    /**
     * 查询 定时心跳列表
     * 
     * @param pMap 参数列表
     */
    public List<TaskScheduleHeartbeat> queryTaskScheduleHeartbeatList(HashMap<String, Object> pMap)throws Exception {
        return getSqlSession().selectList("TaskScheduleHeartbeat.queryTaskScheduleHeartbeatList", pMap);
    }
    
    /**
     * 查询 定时心跳列表
     * 
     * @return 定时心跳列表
     */
    public List<TaskScheduleHeartbeat> queryTaskScheduleHeartbeatList()throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        return getSqlSession().selectList("TaskScheduleHeartbeat.queryTaskScheduleHeartbeatList",params);
    }
    
    /**
     * 查询 定时心跳列表
     * 
     * @return 定时心跳列表
     */
    public List<TaskScheduleHeartbeat> queryTaskScheduleHeartbeatList(TaskScheduleHeartbeat p )throws Exception {
        return getSqlSession().selectList("TaskScheduleHeartbeat.queryTaskScheduleHeartbeatList",p);
    }
    
    /**
     * 统计 定时心跳列表
     * 
     * @return 定时心跳列表
     */
    public List<HashMap<String,Object>> statisticsTaskScheduleHeartbeatInfo(HashMap<String, Object> pMap )throws Exception {
    	List<HashMap<String,Object>> p = null; 
    	p =(List)getSqlSession().selectList("TaskScheduleHeartbeat.statisticsTaskScheduleHeartbeatInfo",p);
    	return p;
    }
    
    
    
    

}
